﻿using System;
using System.Collections.Specialized;
using System.Web.UI;
using PAS.Helper;

namespace PAS
{
    public partial class OptionList : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                
            }
        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            var queryCodition = "";
            if (txtName.Text.Length > 0)
                queryCodition += ((queryCodition.Length == 0 ? " Where " : " And ") + OptionInfo.DbName + " like '%" + txtName.Text + "%' ");
            if (txtGroupName.Text.Length > 0)
                queryCodition += ((queryCodition.Length == 0 ? " Where " : " And ") + OptionInfo.DbGroupName + " like '%" + txtGroupName.Text + "%' ");

            sdList.InnerSql = "Select Id," + OptionInfo.DbName + "," + OptionInfo.DbGroupName + " From " +
                             OptionInfo.DbTableName + queryCodition;
            sdList.SortExpress = OptionInfo.DbGroupName + "," + OptionInfo.DbName;
            sdList.ColumnTypes = new[] { "hidden", "text", "text" };
            sdList.ColumnMemos = new[] { "", "比赛项目名称", "组别名称" };
            sdList.ColumnWidths = new[] { "", "120", "120" };
            sdList.KeyColumnName = "Id";
            sdList.DbTableName = OptionInfo.DbTableName;
            sdList.PageSize = 20;
            sdList.BindData();
        }
    }
}